package ${packageName}.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import ${packageName}.common.R;
import ${packageName}.common.PageResponse;
import ${packageName}.service.${serviceName};
import ${packageName}.model.dto.${dtoName};
import ${packageName}.model.vo.${voName};
/**
* @author 19324
*/
@Tag(name = "${enName}相关接口")
@RestController
@RequestMapping("/${enName}")
@Slf4j
public class ${controllerName}{

    @Resource
    private ${serviceName} ${serviceName?uncap_first};

    //1.新增${enName}
    @Operation(summary = "新增${enName}")
    @PostMapping("/create")
    public R<${booleanName}> create(@RequestBody ${dtoName} ${dtoName?uncap_first}){
        ${serviceName?uncap_first}.create(${dtoName?uncap_first});
        return R.success("新增成功");
    }

    //2.查询By${enName}Id
    @Operation(summary = "查询By${enName}Id")
    @PostMapping("/queryBy${enName}Id")
    public R<${voName}> queryBy${enName}Id(@RequestBody ${dtoName} ${dtoName?uncap_first}){
        ${voName} ${voName?uncap_first}=${serviceName?uncap_first}.queryBy${enName}Id(${dtoName?uncap_first});
        return R.success(${voName?uncap_first},"查询成功");
    }

    //3.查询By其他字段
    @Operation(summary = "查询By其他字段")
    @PostMapping("/queryByOther")
    public R<${voName}> queryByOther(@RequestBody ${dtoName} ${dtoName?uncap_first}){
        ${voName} ${voName?uncap_first}=${serviceName?uncap_first}.queryByOther(${dtoName?uncap_first});
    return R.success(${voName?uncap_first},"查询成功");
    }

    //4.查询所有
    @Operation(summary = "查询所有${enName}")
    @PostMapping("/queryAll")
    public R<${listName}<${voName}>> queryAll(){
        List<${voName}> ${voName?uncap_first}List=${serviceName?uncap_first}.queryAll();
        return R.success(${voName?uncap_first}List,"查询成功");
    }

    //5.删除By${enName}Id
    @Operation(summary = "删除By${enName}Id")
    @PostMapping("/deleteBy${enName}Id")
    public R<${booleanName}> deleteBy${enName}Id(@RequestBody ${dtoName} ${dtoName?uncap_first}){
        ${serviceName?uncap_first}.deleteBy${enName}Id(${dtoName?uncap_first});
        return R.success("删除成功");
    }

    //6.修改By${enName}Id
    @Operation(summary = "修改By${enName}Id")
    @PostMapping("/updateBy${enName}Id")
    public R<${booleanName}> updateBy${enName}Id(@RequestBody ${dtoName} ${dtoName?uncap_first}){
        ${serviceName?uncap_first}.updateBy${enName}Id(${dtoName?uncap_first});
        return R.success("修改成功");
    }

    //7.分页查询${enName}
    @Operation(summary = "分页查询${enName}")
    @PostMapping("/query${enName}ByPage")
    public R<${page_name}<${voName}>> query${enName}ByPage(@RequestBody  ${dtoName} ${dtoName?uncap_first}){
        PageResponse<${voName}> pageResponse=${serviceName?uncap_first}.query${enName}ByPage(${dtoName?uncap_first});
            return R.success(pageResponse,"查询成功");
        }

    }